<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 14:05:02
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:07:59
-->
<template>
  <div class="details">
    <h2 class="title">{{data.title}}</h2>
    <div class="time">{{data.publishTime}}</div>
    <div class="wrapper" v-html="data.content"> </div>
    <div class="btn">
      <el-button :plain="true" @click="clickZan()">点赞</el-button>
    </div>
  </div>
</template>


<script>
import {get} from '../utils/request'
export default {
  data(){
    return{
      id:'',
      data:{}
    }
  },
  methods:{
    //查询风采的详细信息
    findArticleDetails(){
      //数据交互
      get('/index/article/findById?id='+this.id).then(res=>{
        //console.log(res,'----------------');
        if(res.status==200){
          this.data=res.data
        }else{
          this.$message({
            type:'error',
            message:res.message
          })
        }
      })
    },
    clickZan(){
      this.$message({
          message: '点赞成功',
          type: 'success'
        });
    }
  },
  created(){
    //拿到从上一个页面传过来的id值
  //  var id= this.$route.query.id
  //  alert(id)

   this.id=this.$route.query.id

   //调用查询article详情的方法
   this.findArticleDetails()
  }
}
</script>

<style scoped lang='scss'>
.details{
  padding: 14px 0;
  .title{
    font-size: 20px;
    line-height: 3em;
    text-align: center;
    color: #333;
    font-weight: 700;
  }

  .time{
    margin: 1em 0;
    text-align: center;
  }

  .btn{
    text-align: center;
    }   
}
</style>
